package 面向对象高级.代码块;

public class User {
    private String username;
    private String password;
    private long registrationTime;

    {
        System.out.println("新用户的注册");
        registrationTime = System.currentTimeMillis();
    }

    public User() {
        username = registrationTime + "";
        password = "123456";
    }

    public User(String username, String password) {
        this.username = username;
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public long getRegistrationTime() {
        return registrationTime;
    }

    @Override
    public String toString() {
        return "User{" +
                "用户名='" + username + '\'' +
                ", 密码='" + password + '\'' +
                ", 注册时间=" + registrationTime +
                '}';
    }
}

class UserTest{
    public static void main(String[] args) {
        User user1 = new User();
        System.out.println(user1);

        User user2 = new User("张三","888888");
        System.out.println(user2);
    }
}
